package hansot.model.dao;

import hansot.to.MemberTO;
import hansot.to.MenuTO;
import hansot.to.ZipcodeTO;

import java.sql.SQLException;
import java.util.ArrayList;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

public class HansotDAO {
	private SqlMapClientTemplate sqlMap;

	private HansotDAO(SqlMapClientTemplate sqlMap) {
		this.sqlMap = sqlMap;
	}

	public void insertMember(MemberTO mto) throws SQLException {
		sqlMap.insert("insertMember", mto);
	}
	//전체 Menu 조회
	public ArrayList<MenuTO> selectAllMenu() throws SQLException{
		return (ArrayList)sqlMap.queryForList("selectAllMenu");
	}
	//Menu ID로 조회
	public MenuTO selectMenuById(String menuId) throws SQLException{
		return (MenuTO)sqlMap.queryForObject("selectMenuById", menuId);
	}
	//Menu name 조회
	public ArrayList<MenuTO> selectMenuByName(String name) throws SQLException{
		return (ArrayList)sqlMap.queryForList("selectMenuByName", name);
	}
	//메뉴 삽입
	public void insertMenu(MenuTO menuto) throws SQLException{
		sqlMap.insert("insertMenu", menuto);
	}
	//메뉴 수정
	public void updateMenu(MenuTO menuto) throws SQLException{
		sqlMap.update("updateMenu", menuto);
	}
	//메뉴 삭제
	public void deleteMenuById(String id) throws SQLException{
		sqlMap.delete("deleteMenuById", id);
	}
	public ArrayList selectAddressByDong(String dong) throws SQLException{
		return (ArrayList)sqlMap.queryForList("selectZipcodeByDong",dong);
	}
	public void deleteMemberById(String id) throws SQLException{
		sqlMap.delete("deleteMemberById",id);
	}
	public ZipcodeTO selectAddressBySeq(String seq) throws SQLException{
		return (ZipcodeTO) sqlMap.queryForObject("selectZipcodeBySeq",seq);
	}
	
	public MemberTO selectMemberById(String memberId) throws SQLException{
		return (MemberTO)sqlMap.queryForObject("selectMemberById", memberId);
	}

	public void updateMember(MemberTO mto) throws SQLException{
		sqlMap.update("updateMemberById",mto);
	}
	
	public ArrayList<MenuTO> gradeSeaech() throws SQLException{
		return (ArrayList) sqlMap.queryForList("gradeSearch");
	}
}
